package com.bfsuol.bfsuolframework.core.configuration;

import com.bfsuol.bfsuolframework.core.interceptor.I18NInterceptor;
import com.bfsuol.bfsuolframework.core.interceptor.LoginInterceptor;
import com.bfsuol.bfsuolframework.core.interceptor.NoCacheInterceptor;
import com.bfsuol.bfsuolframework.core.interceptor.UrlInterceptor;
import com.bfsuol.bfsuolframework.security.interceptor.SecurityInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ConfigInteceptorLoader implements WebMvcConfigurer {

    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/**/login/**","/**/logon/**","/"
                        ,"/**/register/**","/**/logout/**","/**/fee/alipay/alipayReturn",
                        "/**/fee/alipay/alipayNotify","/**/fee/hxalipay/alipayReturn",
                        "/**/components/fileupload/**","/**/learnerfore/aopeng/**",
                        "/**/index/index","/**.js","/**.html","/**.ftl","/**.css","/**.jpg","/**.png",
                        "/config/**","/font/**","/message/**","/js/**","/ace/**","/layout/**",
                        "/style/**","/common/**","/components/**","/templates/**");

        registry.addInterceptor(new SecurityInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/**/login/**","/**/logon/**","/"
                        ,"/**/register/**","/**/logout/**","/**/fee/alipay/alipayReturn",
                        "/**/fee/alipay/alipayNotify","/**/fee/hxalipay/alipayReturn",
                        "/**/components/fileupload/**","/**/learnerfore/aopeng/**",
                        "/**/index/index","/**.js","/**.html","/**.ftl","/**.css","/**.jpg","/**.png",
                        "/config/**","/font/**","/message/**","/js/**","/ace/**","/layout/**",
                        "/style/**","/common/**","/components/**","/templates/**","/**/index/modifyPwdPre",
                        "/**/index/passwordModify","/**/index/personalInfoPre","/**/index/personalInfoModify");

        registry.addInterceptor(new UrlInterceptor()).addPathPatterns("/**").excludePathPatterns();

        registry.addInterceptor(new I18NInterceptor()).addPathPatterns("/**").excludePathPatterns();


    }
}
